package com.dynamixsoftware.printershare.smb;

public class BufferCache
{
  private static final int MAX_BUFFERS = 16;
  private static Object[] cache = new Object[16];
  private static int freeBuffers = 0;
  
  public static byte[] getBuffer()
  {
    for (;;)
    {
      int i;
      synchronized (cache)
      {
        if (freeBuffers > 0)
        {
          i = 0;
          if (i < 16)
          {
            if (cache[i] == null) {
              break label74;
            }
            byte[] arrayOfByte1 = (byte[])cache[i];
            cache[i] = null;
            freeBuffers = -1 + freeBuffers;
            return arrayOfByte1;
          }
        }
        byte[] arrayOfByte2 = new byte[65535];
        return arrayOfByte2;
      }
      label74:
      i++;
    }
  }
  
  static void getBuffers(SmbComTransaction paramSmbComTransaction, SmbComTransactionResponse paramSmbComTransactionResponse)
  {
    synchronized (cache)
    {
      paramSmbComTransaction.txn_buf = getBuffer();
      paramSmbComTransactionResponse.txn_buf = getBuffer();
      return;
    }
  }
  
  public static void releaseBuffer(byte[] paramArrayOfByte)
  {
    for (;;)
    {
      int i;
      synchronized (cache)
      {
        if (freeBuffers < 16)
        {
          i = 0;
          if (i < 16)
          {
            if (cache[i] != null) {
              break label55;
            }
            cache[i] = paramArrayOfByte;
            freeBuffers = 1 + freeBuffers;
            return;
          }
        }
        return;
      }
      label55:
      i++;
    }
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.smb.BufferCache
 * JD-Core Version:    0.7.0.1
 */